<template>
  <div class="mainpg">
    <div class="main_spac1" style="padding-bottom: 5px">
      <div class="main_white padding10">
        <div class="mainor_form small-top">
          <el-form
            :inline="true"
            :model="form"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="90px"
            id="form"
          >
            <el-form-item label="商品：" prop="goods_spu_id">
              <change-goods-input
                ref="changeGoodsInput"
                url="1"
                @clear="
                  () => {
                    this.form.goods_spu_id = '';
                  }
                "
                @sendValue="
                  (data) => {
                    this.form.goods_spu_id = data.id;
                  }
                "
              ></change-goods-input>
            </el-form-item>
            <el-form-item label="分类：" prop="category_id" class="wid180">
              <el-cascader
                v-model="form.category_id"
                :options="options"
                :props="defaultProps"
                @change="getArticleList"
              ></el-cascader>
            </el-form-item>
            <el-form-item
              label="价格异常："
              prop="wrong_price"
              class="wid180 wrong_price"
            >
              <el-select
                v-model="form.wrong_price"
                placeholder="请选择"
                @change="getArticleList"
              >
                <el-option
                  v-for="item in wrong_price_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <MainFormBtn @reset="reset" @getSearchFor="getArticleList" :loading="listLoading" :showBtn="false">
              <el-button @click="exportMethods" class="mg-r-6"
                >导出
                <el-tooltip class="item" effect="dark" placement="bottom">
                  <div slot="content">注释：不勾选默认导出所有商品！</div>
                  <svg
                    aria-hidden="true"
                    class="navbar_svg new_navbar_svg"
                    width="14"
                    height="14"
                  >
                    <use xlink:href="#icon-summary_question" />
                  </svg> </el-tooltip
              ></el-button>
              <el-button @click="importForm">导入</el-button>
            </MainFormBtn>
          </el-form>
        </div>
        <div class="main-controls-wrap">
          <div>
            <router-link to="/commodity/pricing/record" class="mainor_tea">操作记录</router-link>
          </div>
        </div>
        <div class="main_table">
          <el-table
          ref="multipleTable"
          v-loading="listLoading"
          :data="list.list.data"
          element-loading-text="加载中"
          fit
          border
          highlight-current-row
          @selection-change="handleSelectionChange"
          :header-cell-class-name="this.$verticaline"
          :height="borderHeight - 30"
          :header-cell-style="tableHeightStyle"
          @header-dragend="changeTableWidth"
        >
          <el-table-column type="selection" align="center" />
          <el-table-column
              label="规格ID"
              prop="id"
              :width="tableWidth[hash+'id'] || 80"
            >
          </el-table-column>
          <div v-for="(field, index) in list.field" :key="index">
            <el-table-column
              label="商品名称"
              prop="spu_name.title"
              v-if="field == 1"
              :width="tableWidth[hash+'spu_name.title'] || 180"
            >
              <template slot-scope="scope"
                >{{ scope.row.goods.name }} 【{{
                  scope.row.spu_name ? scope.row.spu_name.title : ""
                }}】</template
              >
            </el-table-column>
            <el-table-column
              label="采购价"
              :render-header="renderHeader_purchase"
              v-if="field == 2"
              class-name="main_hei"
              prop="purchase_price"
              :width="tableWidth[hash+'purchase_price']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_cg">
                    <span
                      :style="{
                        color:
                          parseFloat(scope.row.purchase_price) >
                          parseFloat(scope.row.market_price)
                            ? 'red'
                            : '',
                      }"
                    >
                      {{ scope.row.purchase_price }}</span
                    >

                    <!-- 注释  表头 采购价 默认调用最近一次采购价 不可编辑 -->
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_cg')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.purchase_price"
                      placeholder="采购价"
                      class="wid80"
                    ></el-input>
                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.purchase_price,
                            scope.$index,
                            'freight_cg',
                            'purchase_price'
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.purchase_price =
                            scope.row.purchase_price_data),
                            (scope.row.freight_cg = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="市场价"
              v-if="field == 3"
              class-name="main_hei"
              prop="market_price"
              :width="tableWidth[hash+'market_price']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_jc">
                    {{ scope.row.market_price }}
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_jc')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.market_price"
                      placeholder="市场价"
                      class="wid80"
                    ></el-input>
                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.market_price,
                            scope.$index,
                            'freight_jc',
                            'market_price'
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.market_price =
                            scope.row.market_price_data),
                            (scope.row.freight_jc = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="时价"
              prop="current_price"
              class-name="main_hei renderHeader_current"
              v-if="field == 4"
              :width="tableWidth[hash+'current_price'] || 120"
            >
              <template slot-scope="scope">
                <el-switch
                  v-model="scope.row.current_price"
                  @change="
                    (val) => {
                      elswitch(val, scope.row.id, 'current_price');
                    }
                  "
                  active-color="#03A98E"
                  active-text="开"
                  inactive-text="关"
                  class="mainor_switch"
                ></el-switch>
              </template>
            </el-table-column>

            <!-- 互调比 -->
            <el-table-column
              label="互调比"
              prop="package_num"
              :render-header="renderHeader_packageNum"
              class-name="main_hei"
              v-if="field == 5"
              :width="tableWidth[hash+'package_num']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_package_num">
                    {{ scope.row.package_num }}
                    <svg
                      v-if="scope.row.is_update=='yes'"  
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_package_num')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.package_num"
                      placeholder="互调比"
                      class="wid80"
                    ></el-input>
                    <!-- is_update 为no的时候不展示 -->
                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.package_num,
                            scope.$index,
                            'freight_package_num',
                            'package_num'
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.package_num = scope.row.package_num_data),
                            (scope.row.freight_package_num = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>

            <!-- 互调比结束 -->

            <!-- <el-table-column
                label="首页推荐"
                width="120"
                class-name="main_hei"
                v-if="field == 5"
              >
                <template slot-scope="scope">
                  <el-switch
                    v-model="scope.row.goods.is_recommend"
                    @change="
                      (val) => {
                        elswitch(val, scope.row.goods_id, 'is_recommend');
                      }
                    "
                    active-color="#03A98E"
                    active-text="开"
                    inactive-text="关"
                    class="mainor_switch"
                  ></el-switch>
                </template>
              </el-table-column> -->

            <!-- <el-table-column
                label="排序"
                prop="goods.sort"
                class-name="main_hei"
                v-if="field == 6"
              >
                <template slot-scope="scope">
                  <div class="mainus_pe">
                    <div v-if="!scope.row.freight_order">
                      {{ scope.row.goods.sort }}
                      <svg
                        aria-hidden="true"
                        class="main_page_svg"
                        width="13"
                        height="13"
                        @click="freighta(scope.$index, 'freight_order')"
                      >
                        <use xlink:href="#icon-commodity_modify" />
                      </svg>
                    </div>
                    <div v-else class="boxnr">
                      <el-input
                        v-model="scope.row.goods.sort"
                        placeholder="排序"
                        class="wid80"
                      ></el-input>
                      <div class="boxnr">
                        <svg
                          aria-hidden="true"
                          class="main_page_svg marginLeft5"
                          width="20"
                          height="20"
                          @click="
                            inputBlur(
                              scope.row.goods.sort,
                              scope.$index,
                              'freight_order',
                              'sort'
                            )
                          "
                        >
                          <use xlink:href="#icon-index_tick" />
                        </svg>
                        <svg
                          aria-hidden="true"
                          class="main_page_svg marginLeft5"
                          width="12"
                          height="12"
                          @click="
                            (scope.row.goods.sort = scope.row.goods.sort_data),
                              (scope.row.freight_minimum = false)
                          "
                        >
                          <use xlink:href="#icon-index_cross" />
                        </svg>
                      </div>
                    </div>
                  </div>
                </template>
              </el-table-column> -->
            <el-table-column
              label="起定量"
              prop="minimum"
              class-name="main_hei"
              v-if="field == 7"
              :width="tableWidth[hash+'minimum']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_minimum">
                    {{ scope.row.minimum }}
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_minimum')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.minimum"
                      placeholder="起订量"
                      class="wid80"
                    ></el-input>
                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.minimum,
                            scope.$index,
                            'freight_minimum',
                            'minimum'
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.minimum = scope.row.minimum_data),
                            (scope.row.freight_minimum = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>

            <el-table-column
              label="损耗率"
              prop="attrition_rate"
              class-name="main_hei"
              v-if="field == 8"
              :width="tableWidth[hash+'attrition_rate']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_attrition_rate">
                    {{ scope.row.attrition_rate }}%
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_attrition_rate')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.attrition_rate"
                      placeholder="损耗率"
                      class="wid80"
                    ></el-input>
                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.attrition_rate,
                            scope.$index,
                            'freight_attrition_rate',
                            'attrition_rate'
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.attrition_rate =
                            scope.row.attrition_rate_data),
                            (scope.row.freight_attrition_rate = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>

            <!-- <el-table-column
                label="指定库存"
                prop="designated_inventory"
                class-name="main_hei"
                v-if="field == 9"
              >
                <template slot-scope="scope">
                  <div class="mainus_pe">
                    <div v-if="!scope.row.freight_designated_inventory">
                      {{ scope.row.designated_inventory }}
                      <svg
                        aria-hidden="true"
                        class="main_page_svg"
                        width="13"
                        height="13"
                        @click="
                          freighta(scope.$index, 'freight_designated_inventory')
                        "
                      >
                        <use xlink:href="#icon-commodity_modify" />
                      </svg>
                    </div>
                    <div v-else class="boxnr">
                      <el-input
                        v-model="scope.row.designated_inventory"
                        placeholder="指定库存"
                        class="wid80"
                      ></el-input>
                      <div class="boxnr svg_box">
                        <svg
                          aria-hidden="true"
                          class="main_page_svg marginLeft5"
                          width="20"
                          height="20"
                          @click="
                            inputBlur(
                              scope.row.designated_inventory,
                              scope.$index,
                              'freight_designated_inventory',
                              'designated_inventory'
                            )
                          "
                        >
                          <use xlink:href="#icon-index_tick" />
                        </svg>
                        <svg
                          aria-hidden="true"
                          class="main_page_svg marginLeft5"
                          width="12"
                          height="12"
                          @click="
                            (scope.row.designated_inventory =
                              scope.row.designated_inventory_data),
                              (scope.row.freight_designated_inventory = false)
                          "
                        >
                          <use xlink:href="#icon-index_cross" />
                        </svg>
                      </div>
                    </div>
                  </div>
                </template>
              </el-table-column> -->

            <el-table-column
              label="描述"
              prop="describe"
              class-name="main_hei"
              v-if="field == 12"
              :width="tableWidth[hash+'describe']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div>
                    {{ scope.row.describe }}
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="addDescribe(scope)"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>
                </div>
              </template>
            </el-table-column>

            <el-table-column
              label="售卖状态"
              :render-header="renderHeader_status"
              class-name="main_hei"
              v-if="field == 13"
              prop="status"
              :width="tableWidth[hash+'status'] || 140"
            >
              <template slot-scope="scope">
                <el-switch
                  v-model="scope.row.status"
                  @change="
                    (val) => {
                      elswitch(val, scope.row.id, 'status');
                    }
                  "
                  active-color="#03A98E"
                  active-text="开"
                  inactive-text="关"
                  class="mainor_switch"
                ></el-switch>
              </template>
            </el-table-column>

            <el-table-column
              label="折扣率"
              prop="discount"
              class-name="main_hei"
              v-if="field == 14"
              :width="tableWidth[hash+'discount']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_discount_rate">
                    {{ scope.row.discount }}
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_discount_rate')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>

                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.discount"
                      placeholder="折扣率"
                      class="wid80"
                    ></el-input>

                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.discount,
                            scope.$index,
                            'freight_discount_rate',
                            'discount',
                            scope.row
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.discount = scope.row.discount_rate_data),
                            (scope.row.freight_discount_rate = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>

            <el-table-column
              label="分拣宽容度"
              prop="tolerance"
              class-name="main_hei"
              v-if="field == 15"
              :width="tableWidth[hash+'tolerance']"
            >
              <template slot-scope="scope">
                <div class="mainus_pe">
                  <div v-if="!scope.row.freight_tolerance_rate">
                    {{ scope.row.tolerance }}
                    <svg
                      aria-hidden="true"
                      class="main_page_svg"
                      width="13"
                      height="13"
                      @click="freighta(scope.$index, 'freight_tolerance_rate')"
                    >
                      <use xlink:href="#icon-commodity_modify" />
                    </svg>
                  </div>

                  <div v-else class="boxnr">
                    <el-input
                      v-model="scope.row.tolerance"
                      placeholder="请输入1-100以内的数值"
                      class="wid80"
                    ></el-input>

                    <div class="boxnr svg_box">
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="20"
                        height="20"
                        @click="
                          inputBlur(
                            scope.row.tolerance,
                            scope.$index,
                            'freight_tolerance_rate',
                            'tolerance',
                            scope.row
                          )
                        "
                      >
                        <use xlink:href="#icon-index_tick" />
                      </svg>
                      <svg
                        aria-hidden="true"
                        class="main_page_svg marginLeft5"
                        width="12"
                        height="12"
                        @click="
                          (scope.row.tolerance = scope.row.tolerance_rate_data),
                            (scope.row.freight_tolerance_rate = false)
                        "
                      >
                        <use xlink:href="#icon-index_cross" />
                      </svg>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>

            <!-- <el-table-column
                label="分拣转换"
                width="120"
                :render-header="renderHeader_trans"
                class-name="main_hei"
                v-if="field==11"
              >
                <template slot-scope="scope">
                  <el-switch
                    v-model="scope.row.is_transfer"
                    @change="((val)=>{elswitch(val,scope.row.id,'is_transfer')})"
                    active-color="#03A98E"
                    active-text="开"
                    inactive-text="关"
                    class="mainor_switch"
                  ></el-switch>
                </template>
              </el-table-column> -->
            <!-- <el-table-column
                label="小数加购"
                width="120"
                :render-header="renderHeader_float"
                class-name="main_hei"
                v-if="field==12"
              >
                <template slot-scope="scope">
                  <el-switch
                    v-model="scope.row.is_float"
                    @change="((val)=>{elswitch(val,scope.row.id,'is_float')})"
                    active-color="#03A98E"
                    active-text="开"
                    inactive-text="关"
                    class="mainor_switch"
                  ></el-switch>
                </template>
              </el-table-column> -->
              <el-table-column
                label="分类"
                prop="category_name"
                v-if="field == 16"
                :width="tableWidth[hash+'category_name'] || 180"
              ></el-table-column>
          </div>
          <el-table-column
            label="管理操作"
            align="center"
            fixed="right"
            prop="operate"
            :width="tableWidth[hash+'operate'] || 200"
            class-name="main_hei"
          >
            <template slot="header">
              <table-header-setting
                @openHeader="dialogFormVisible = true"
              ></table-header-setting>
            </template>
            <template slot-scope="scope">
              <router-link :to="'/commodity/pricing/edit/' + scope.row.id">
                <el-link type="primary">编辑</el-link>
              </router-link>
              <el-link type="danger" @click="delet(scope.$index, scope.row.id)"
                >删除</el-link
              >
            </template>
          </el-table-column>
        </el-table>
        </div>
        <div class="main_page boxdq">
          <div></div>
          <!-- 分页 -->
          <div class="main_page_r">
            <MainPagination
              :current-page="current.page"
              :page-sizes="[20, 30, 50, 100]"
              :page-size="limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalCount"
              background
              @size-change="changeLimit"
              @current-change="changePage"
            />
          </div>
        </div>

        <el-dialog
          title="表头设置"
          :visible.sync="dialogFormVisible"
          class="main_dialog dialog500"
          @close="type = list.field"
        >
          <div class="set_sort">
            <div class="set_none_show">
              <el-checkbox-group v-model="type">
                <el-checkbox
                  v-for="(Header, index) in Header"
                  :key="index"
                  :label="Header.id"
                  :disabled="Header.disabled"
                  >{{ Header.name }}</el-checkbox
                >
              </el-checkbox-group>
            </div>
            <div class="set_header_sort">
              <div class="set_sort_ab">
                <draggable
                  chosen-class="chosen"
                  v-model="Header"
                  animation="500"
                >
                  <transition-group>
                    <li
                      class="set_sort_ab_border"
                      v-for="item in Header"
                      :key="item.id"
                    >
                      <div>
                        <span class="el-icon-d-caret"></span>
                        <span>{{ item.name }}</span>
                      </div>
                      <svg-icon icon-class="index_move" />
                    </li>
                  </transition-group>
                </draggable>
              </div>
            </div>
          </div>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="setupmine" v-repeatClick
              >确 定</el-button
            >
          </div>
        </el-dialog>

        <el-dialog
          title="导出"
          :visible.sync="exportFormVisible"
          class="main_dialog dialog500"
          @close="type = list.field"
        >
          <div class="export">你选择了{{ this.selectArr.length }}条数据</div>
          <div slot="footer" class="dialog-footer">
            <el-button @click="exportFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="exportConfim" v-repeatClick
              >确 定</el-button
            >
          </div>
        </el-dialog>

        <!-- 描述 -->
        <el-dialog
          title="SKU维护"
          label-position="left"
          :visible.sync="dialogDescribeVisible"
          width="30%"
        >
          <div class="dialog_padding20_30">
            <el-form>
              <el-form-item label="描述：" label-position="top">
                <el-input
                  v-model="describeForm.describe"
                  type="textarea"
                  autocomplete="off"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogDescribeVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmDescribe">确 定</el-button>
          </div>
        </el-dialog>
      </div>
    </div>

    <!-- 导入 -->
    <el-dialog
      title="导入"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :visible.sync="importFormVisible"
      class="main_dialog dialog550"
    >
      <div class="dialog_padding20_30">
        <div class="importForm">
          <el-upload
            class="upload-demo"
            drag
            :action="skuimport"
            :on-success="importSuccess"
            :on-error="importerr"
            :data="importdata"
            :headers="{
              Authorization: getToken(),
            }"
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">
              将文件拖到此处，或<em>点击上传</em>
            </div>
          </el-upload>
        </div>
        <div class="progress" v-if="percentShow">
          <el-progress
            :text-inside="true"
            :stroke-width="20"
            :percentage="percent"
            color="#19B098"
          ></el-progress>
        </div>
        <div class="notice" v-if="percentShow">
          <div class="importtips">
            <div v-for="(item, index) in reverseSum" :key="index">
              <!-- <p v-if="item.type == 1" :key="index">
              商品:{{ item.name }}，同步已成功
            </p> -->
              <p v-if="item.type == 2" :key="index" class="fail">
                商品:{{ item.name }}，同步失败
              </p>
            </div>
            <p v-if="percent == 100" class="success">商品同步结束！</p>
          </div>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button @click="importFormConfirm(0)">取 消</el-button>
        <el-button type="primary" @click="importFormConfirm(1)" v-repeatClick
          >确 定</el-button
        >
      </div></el-dialog
    >
  </div>
</template>

<script>
import { mixins } from "@/mixins/index.js";
import {
  sku_index,
  goods_delete,
  sku_changeStatus,
  goods_changeStatus,
  sku_changeField,
  sku_batchStatus,
  export_skulog_index,
  sku_isbathcStaus,
} from "@/api/commodity/commodity_Pricing";
import { field_getField } from "@/api/sort";
import { skuimport } from "@/api/currency.js";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { field_save } from "@/api/currency";
import { recursion, category, exportMethod } from "@/utils/index";
import { resetRouter } from "@/router";
import { mapGetters } from "vuex";
import draggable from "vuedraggable";
export default {
  mixins: [mixins],
  components: {
    draggable,
  },
  computed: {
    ...mapGetters(["avatar"]),
    reverseSum() {
      return this.percent_list;
    },
  },
  directives: {
    // 聚焦元素
    focus: {
      inserted(el) {
        el.querySelector("input").focus();
      },
    },
  },
  data() {
    return {
      exportMethod,
      // 搜索
      form: {
        goods_spu_id: "",
        pid: "",
        category_id: [],
        wrong_price: "",
      },
      skuimport: skuimport,
      // 分页
      current: {
        page: 1,
        per_page: 20,
      },
      limit: 20,
      totalCount: 1,
      // 列表数据
      list: {
        list: {
          data: [],
        },
      },
      listLoading: false,
      // 表头设置
      dialogFormVisible: false,
      exportFormVisible: false,
      dialogDescribeVisible: false,
      importFormVisible: false,
      importdata: {
        uid: "",
      },
      describeForm: {
        describe: "",
        id: "",
      },
      type: [],
      Header: [
        {
          id: 1,
          name: "商品名称",
          disabled: true,
        },

        {
          id: 2,
          name: "采购价",
          disabled: true,
        },
        {
          id: 3,
          name: "市场价",
          disabled: true,
        },
        {
          id: 4,
          name: "时价",
          disabled: false,
        },
        {
          id: 5,
          name: "互调比",
          disabled: false,
        },
        // {
        //   id: 5,
        //   name: "首页推荐",
        //   disabled: true,
        // },

        // {
        //   id: 6,
        //   name: "排序",
        //   disabled: false,
        // },
        {
          id: 7,
          name: "起定量",
          disabled: false,
        },
        {
          id: 8,
          name: "损耗率",
          disabled: false,
        },

        // {
        //   id: 10,
        //   name: "分拣转换",
        //   disabled: false,
        // },
        // {
        //   id: 11,
        //   name: "小数加购",
        //   disabled: false,
        // },
        {
          id: 12,
          name: "描述",
          disabled: false,
        },
        {
          id: 13,
          name: "售卖状态 ",
          disabled: false,
        },
        {
          id: 14,
          name: "折扣率 ",
          disabled: false,
        },
        {
          id: 15,
          name: "分拣宽容度 ",
          disabled: false,
        },
        {
          id: 16,
          name: "分类",
          disabled: false,
        },
      ],
      // 分类
      options: [],
      defaultProps: {
        children: "selfNext",
        label: "title",
        value: "id",
        checkStrictly: true,
      },
      //价格异常
      wrong_price_options: [
        { value: 1, label: "采购价>市场价" },
        { value: 2, label: "采购价<=0" },
        { value: 3, label: "市场价<=0" },
        { value: 4, label: "所有" },
      ],
      // 全选
      selectArr: [],
      // 焦点
      offsetParent: true,

      // 导入
      percent_gs: 0,
      percent: 0,
      percentShow: false,
      percent_list: [],
      importArrLength: 1,
    };
  },
  // 刷新
  inject: ["reload"],
  created() {
    
  },
  mounted() {
    this.sort_data();

    window.Echo.channel("batchImport." + this.avatar.company_id).listen(
      "BatchImportEvent",
      (e) => {
        console.log(e);
        this.importArrLength = e.notice.count;
        this.percentShow = true;
        this.percent_gs = parseInt(this.percent_gs) + 1;
        if ((this.percent_gs / this.importArrLength) * 100 >= 100) {
          this.percent = 100;
          return;
        }
        this.percent =
          this.percent_gs / this.importArrLength
            ? parseInt((this.percent_gs / this.importArrLength) * 100)
            : 0;
        if (e.notice.msg == "ok") {
          this.percent_list.push({
            num: this.percent,
            type: 1,
            name: e.notice.name,
          });
        } else if (e.notice.msg == "err") {
          this.percent_list.push({
            num: this.percent,
            type: 2,
            name: e.notice.name,
          });
        }
      }
    );
  },
  methods: {
    startGetting() {
      this.getArticleList();
    },
    //排序
    sort_data() {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { type: 2 }
      );
      field_getField(data).then((res) => {
        let arry = JSON.parse(res.data.info.sort);
        if (arry || arry.length) {
          this.Header.sort((a, b) => {
            return arry.indexOf(a.id) - arry.indexOf(b.id);
          });
        }
      });
    },
    // 导入
    importForm() {
      this.importFormVisible = true;
      this.importdata.uid = this.avatar.id;
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
          ),
        },
        apiUrl().name
      );
    },
    importFormConfirm(type) {
      this.percentShow = false;
      if (type == 0) {
        this.percent = 0;
        this.percent_gs = 0;
        this.percent_list = [];
        this.importFormVisible = false;
      } else if (type == 1) {
        this.percent = 0;
        this.percent_gs = 0;
        this.percent_list = [];
        this.importFormVisible = false;
        this.sku_index();
      }
    },
    importerr(err, file, fileList) {
      // console.log(err);
    },
    importSuccess(response, file, fileList) {
      if (response.errcode != 0) {
        this.$message.error(response.errmsg);
      }
      // console.log(response);
    },
    // 监听全选
    handleSelectionChange(val) {
      this.selectArr = [];
      val.map((item) => {
        this.selectArr.push(item.id);
      });
    },
    exportMethods() {
      if (this.selectArr.length > 0) {
        this.exportFormVisible = true;
      } else {
        this.$confirm("是否导出全部的商品SKU", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.exportConfim();
          })
          .catch(() => {});
      }
    },
    // 导出确认
    exportConfim() {
      let form = JSON.parse(JSON.stringify(this.form));
      form.pid = form.category_id[0] ? form.category_id[0] : "";
      form.category_id = category(form.category_id);
      form.ids = this.selectArr.join("-");
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, form)) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        form
      );
      const notify = this.$notify.info({
        title: "开始导出...",
        type: "success",
        duration: 0,
      });
      export_skulog_index(data)
        .then((res) => {
          this.exportMethod(res, "sku导出", notify);
        })
        .catch(() => {
          this.$message.error("导出失败");
        });
      this.exportFormVisible = false;
    },
    // 采购价 ？注释
    renderHeader_purchase(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content: "近一次采购价！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 互调比 ？注释
    renderHeader_packageNum(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content: "产生数据不能编辑互调比！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 库存价 ？注释
    renderHeader_inventory(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content:
                "入库时根据当日的采购价和入库数量与当前库存价和库存数量进行加权平均计算得来！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 时价？注释
    renderHeader_current(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h(
        "div",
        {
          class: "boxnr",
        },
        [
          // h即为cerateElement的简写
          // 在div里面插入span
          h(
            "div",
            {
              class: "maincl_px",
              style: "margin-right: 5px;",
            },
            [
              h("em", {
                style: this.selectArr.length != 0 ? "" : "display:none;",
                class: "maincl_pxe",
                // 表示内容
                domProps: {
                  innerHTML:
                    '<svg aria-hidden="true" width="12" height="12" > <use xlink:href="#icon-commodity_open" /></svg>',
                },
                on: {
                  click: () => {
                    this.check(
                      "确定为选中商品批量开启时价吗？",
                      1,
                      "current_price"
                    );
                    // console.log(`${column.label}   ${$index}`);
                  },
                },
              }),
              h("em", {
                style:
                  this.selectArr.length != 0 ? "top:-2px;" : "display:none;",
                class: "maincl_pxe",
                // 表示内容
                domProps: {
                  innerHTML:
                    '<svg aria-hidden="true" width="12" height="12" > <use xlink:href="#icon-commodity_close" /></svg>',
                },
                on: {
                  click: () => {
                    this.check(
                      "确定为选中商品批量关闭时价吗？",
                      0,
                      "current_price"
                    );
                    // console.log(`${column.label}   ${$index}`);
                  },
                },
              }),
            ]
          ),
          h("span", {
            // 表示内容
            domProps: {
              innerHTML: column.label,
            },
            on: {
              click: () => {
                console.log(`${column.label}   ${$index}`);
              },
            },
          }),
          h(
            "el-tooltip",
            {
              // 表示属性
              attrs: {
                effect: "dark",
                content: "开启后，移动端就不会显示价格而是以“时价”两字代替！",
                placement: "top",
              },
            },
            [
              h("i", {
                style: "margin-left: 5px;margin-top:-1px;",
                class: "el-icon-question table-msg",
              }),
            ]
          ),
        ]
      );
    },
    // 上架状态？注释
    renderHeader_status(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h(
        "div",
        {
          class: "boxnr",
        },
        [
          // h即为cerateElement的简写
          // 在div里面插入span
          h(
            "div",
            {
              class: "maincl_px",
              style: "margin-right: 5px;",
            },
            [
              h("em", {
                style: this.selectArr.length != 0 ? "" : "display:none;",
                class: "maincl_pxe",
                // 表示内容
                domProps: {
                  innerHTML:
                    '<svg aria-hidden="true" width="12" height="12" > <use xlink:href="#icon-commodity_open" /></svg>',
                },
                on: {
                  click: () => {
                    this.check("确定选中商品批量【上架】吗？", 1, "status");
                    // console.log(`${column.label}   ${$index}`);
                  },
                },
              }),
              h("em", {
                style:
                  this.selectArr.length != 0 ? "top:-2px;" : "display:none;",
                class: "maincl_pxe",
                // 表示内容
                domProps: {
                  innerHTML:
                    '<svg aria-hidden="true" width="12" height="12" > <use xlink:href="#icon-commodity_close" /></svg>',
                },
                on: {
                  click: () => {
                    this.check("确定选中商品批量【下架】吗？", 0, "status");
                    // console.log(`${column.label}   ${$index}`);
                  },
                },
              }),
            ]
          ),
          h("span", {
            // 表示内容
            domProps: {
              innerHTML: column.label,
            },
            on: {
              click: () => {
                console.log(`${column.label}   ${$index}`);
              },
            },
          }),
        ]
      );
    },
    // 分拣转换 ？注释
    renderHeader_trans(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content:
                "只适用规格，一旦开启在分拣时会自动用分拣量/转换率，得到最终的分拣量，如：客户下了2个3斤装的白菜，像蔬菜一般都是散装，分拣时只会把散装的白菜放到称上分拣，到差不多6斤时就保存，这时系统会自动用6/3得到最终的分拣量！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 小数加购 ？注释
    renderHeader_float(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content:
                "开启后，移动端在使用键盘输入数量加入购物车时，就不能选择小数点！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    // 批量弹窗
    check(name, type, pd) {
      console.log(name, type, pd);
      this.$confirm(name, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          if (pd == "is_batch") {
            this.isbatch(type);
          } else {
            this.batch(type);
          }
        })
        .catch(() => {});
    },
    // 批量处理
    batch(type) {
      console.log(type, "售卖状态");
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { status: type })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { ids: JSON.stringify(this.selectArr), status: type }
      );
      sku_batchStatus(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "批量处理成功",
            type: "success",
          });
          this.$refs.multipleTable.clearSelection();
          this.sku_index();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },

    // 批次处理
    isbatch(type) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { is_batch: type })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { ids: JSON.stringify(this.selectArr), is_batch: type }
      );
      sku_isbathcStaus(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "批量处理成功",
            type: "success",
          });
          this.$refs.multipleTable.clearSelection();
          this.sku_index();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },

    // 点击排序
    freighta(index, name) {
      if (this.offsetParent) {
        this.list.list.data[index][name] = !this.list.list.data[index][name];
      }
    },
    // 焦点离开排序
    inputBlur(val, index, name, type, row) {
      this.offsetParent = false;
      let bol;
      try {
        bol = val.toString().split(".")[1].length <= 2;
      } catch (error) {
        bol = true;
      }
      if (
        (/^(\d+\.?)?\d{0,2}$/.test(parseFloat(val)) && val != "" && bol) ||
        type == "discount" ||
        val == 0
      ) {
        this.list.list.data[index][name] = !this.list.list.data[index][name];
        this.offsetParent = true;
        if (type == "sort") {
          this.goods_change(val, this.list.list.data[index].goods.id, type);
          return;
        }
        if (type == "discount") {
          let num = Number(val);
          let len;
          try {
            len = val.toString().split(".")[1].length > 3;
          } catch (error) {
            len = false;
          }
          if (num < 0 || num > 1 || len) {
            this.$message.error("折扣 必须为0到1之间且保留三位小数");
            row.discount = row.discount_rate_data;
            return;
          } else {
            this.goods_change(val, this.list.list.data[index].id, type);
            return;
          }
        }
        if (type == "tolerance") {
          if (/^(1|([1-9]\d{0,1})|100)$/.test(parseFloat(val))) {
            this.goods_change(val, this.list.list.data[index].id, type);
            return;
          } else {
            this.$message.error("分拣宽容度 必须为0到100之间且必须为整数");
            row.tolerance = row.tolerance_rate_data;
            return;
          }
        }
        this.goods_change(val, this.list.list.data[index].id, type);
      } else {
        this.$message.error("保存内容不能为空");
        this.offsetParent = true;
      }
    },
    // 查看价格开关
    elswitch(val, id, type) {
      if (type == "status") {
        this.sku_changeStatus(val ? 1 : 0, id);
      } else {
        this.goods_change(val ? 1 : 0, id, type);
      }
    },
    // 上架状态开关切换
    sku_changeStatus(val, id) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { id: id, status: val })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { id: id, status: val }
      );
      sku_changeStatus(data).then((res) => {
        // this.sku_index();
        if (res.errcode == 0) {
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 其他开关切换
    goods_change(val, id, type) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(
              Object.assign(apiUrl().name, { id: id, type: type, value: val })
            ) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { id: id, type: type, value: val }
      );
      if (type == "is_recommend" || type == "sort") {
        goods_changeStatus(data).then((res) => {
          // this.sku_index();
          if (res.errcode == 0) {
          } else {
            this.$message.error(res.errmsg);
          }
        });
      } else {
        sku_changeField(data).then((res) => {
          // this.sku_index();
          if (res.errcode == 0) {
          } else {
            this.$message.error(res.errmsg);
          }
        });
      }
    },
    // 设置确认
    setupmine(val) {
      let arry = [];
      let arrys = [];
      this.Header.map((e) => {
        arrys.push(e.id);
        this.type.map((p) => {
          if (e.id == p) {
            arry.push(e.id);
            return;
          }
        });
      });
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { type: 2 })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { type: 2, fields: JSON.stringify(arry), sort: JSON.stringify(arrys) }
      );
      field_save(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "设置成功",
            type: "success",
          });
          this.reload();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 分页
    changeLimit(pageSize) {
      this.current.per_page = pageSize;
      this.sku_index();
    },
    changePage(page) {
      this.current.page = page;
      this.sku_index();
    },
    // 搜索
    getArticleList() {
      this.current.page = 1;
      this.sku_index();
    },
    // 重置
    reset() {
      this.$refs["userListFrom"].resetFields();
      this.$refs["changeGoodsInput"].name = "";
      this.getArticleList();
    },
    // 删除
    delet(index, id) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { id: id, type: 2 })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { id: id, type: 2 }
      );
      this.$confirm("是否删除SKU?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          goods_delete(data).then((res) => {
            if (res.errcode == 0) {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.list.list.data.splice(index, 1);
            } else {
              this.$message.error(res.errmsg);
            }
          });
        })
        .catch(() => {});
    },
    // 列表
    sku_index() {
      this.listLoading = true;
      let form = JSON.parse(JSON.stringify(this.form));
      form.pid = form.category_id[0] ? form.category_id[0] : "";
      form.category_id = category(form.category_id);
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, form, this.current)) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        form,
        this.current
      );
      sku_index(data).then((res) => {
        this.listLoading = false;
        if (res.errcode == 0) {
          this.options = recursion(res.data.categoryList, true);
          res.data.list.data.map((e) => {
            e.market_price_data = e.market_price;
            e.purchase_price_data = e.purchase_price;
            e.attrition_rate_data = e.attrition_rate;
            e.tolerance_rate_data = e.tolerance;
            e.discount_rate_data = e.discount;
            e.designated_inventory_data = e.designated_inventory;
            e.package_num_data = e.package_num;
            e.minimum_data = e.minimum;
            e.goods.sort_data = e.goods.sort;
            e.freight_cg = false;
            e.freight_jc = false;
            e.freight_order = false;
            e.freight_minimum = false;
            e.freight_attrition_rate = false;
            e.freight_discount_rate = false;
            e.freight_tolerance_rate = false;
            e.freight_designated_inventory = false;
            e.freight_package_num = false;
            e.is_float = e.is_float == 0 ? false : true;
            e.status = e.status == 0 ? false : true;
            e.is_batch = e.is_batch == 0 ? false : true;
            e.current_price = e.current_price == 0 ? false : true;
            e.is_transfer = e.is_transfer == 0 ? false : true;
            e.goods.is_recommend = e.goods.is_recommend == 0 ? false : true;
          });
          this.type = res.data.field;
          this.list = res.data;
          this.totalCount = res.data.list.total;
          // 在数据更新后执行
          this.$nextTick(() => {
            // myTable是表格的ref属性值
            if (this.$refs.multipleTable && this.$refs.multipleTable.doLayout) {
              this.$refs.multipleTable.doLayout();
            }
          });
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    changeinput(val, scope, type) {
      if (/^(\d+\.?)?\d{0,2}$/.test(parseFloat(val)) && val != "") {
      } else {
        this.$message.error("请输入正确的数字");
      }
    },

    // 描述事件
    addDescribe(scope) {
      this.describeForm.describe = scope.row.describe;
      this.describeForm.id = scope.row.id;
      this.dialogDescribeVisible = true;
    },
    confirmDescribe() {
      let id = this.describeForm.id;
      let val = this.describeForm.describe;
      this.dialogDescribeVisible = false;
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(
              Object.assign(apiUrl().name, {
                id: id,
                type: "describe",
                value: val,
              })
            ) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { id: id, type: "describe", value: val }
      );
      sku_changeField(data).then((res) => {
        if (res.errcode == 0) {
          this.sku_index();
        } else {
          this.$message.error("修改出错");
        }
      });
    },
  },
  activated() {
    this.getNumerical(160);
    // 列表
    this.sku_index();
  },
};
</script>
<style lang="scss" scoped>
/deep/.el-table--border .el-table__cell:first-child .cell{
  padding-left: 14px;
}
.mainor_form form {
  width: calc(100% - 180px);
}
.export {
  text-align: center;
  font-size: 18px;
  margin-top: 20px;
}
// 导入
.importForm {
  display: flex;
  align-items: center;
  justify-content: center;
}
.progress {
  padding: 15px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.notice {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .importtips {
    overflow-y: scroll;
    width: 350px;
    height: 84px;
    height: 84px;
    background: #ffffff;
    border: 1px solid #d8d8d8;
    padding: 10px 15px;
    .fail {
      color: #ff5a5a;
      line-height: 1.2;
      font-size: 12px;
    }
    .success {
      color: #19b098;
      line-height: 1.2;
      font-size: 12px;
    }
  }
}

/deep/.el-upload-dragger {
  width: 300px;
  height: 150px;
}
/deep/ .el-dialog__body {
  padding: 5px 20px;
  margin: 0 auto;
}
/deep/ .el-progress {
  width: 350px;
}
// 对错 svg展示
.svg_box {
  display: flex;
  flex-direction: column;
  transform: translateY(-2px);
}
.marginLeft5 {
  margin-left: 5px !important;
  margin-top: 1px;
  margin-bottom: 1px;
}
.new_navbar_svg {
  vertical-align: top;
}
/deep/.el-dialog__body {
  padding: 0;
}
/deep/.el-checkbox {
  margin-right: 30px !important;
}
/deep/.el-checkbox {
  flex: 30%;
}
/deep/.el-checkbox-group {
  display: flex;
  flex-wrap: wrap;
}

/deep/ .el-form-item--small.el-form-item {
  margin-bottom: 10px !important;
}
</style>
